package com.quick.develop.flowable.mapper;

import com.quick.develop.flowable.domain.rule.BpmExampleRule;
import com.quick.develop.flowable.utils.mybatis.mapper.BaseMapperX;
import com.quick.develop.flowable.utils.mybatis.query.QueryWrapperX;

import java.util.List;
import java.util.Map;

public interface BpmExampleRuleMapper extends BaseMapperX<BpmExampleRule> {
    default List<BpmExampleRule> getBpmExampleRule(BpmExampleRule bpmExampleRule){
        return selectList(new QueryWrapperX<BpmExampleRule>()
                .eq("MODEL_KEY",bpmExampleRule.getModelKey())
                .eq("BUSINESS_KEY",bpmExampleRule.getBusinessKey())
                .eq("NODE_CODE",bpmExampleRule.getNodeCode()));

    }
    public int removeAll(BpmExampleRule bpmExampleRule);

    default List<BpmExampleRule> getBpmExampleRuleByBussKey(String businessKey){
        return selectList(new QueryWrapperX<BpmExampleRule>()
                .eq("BUSINESS_KEY",businessKey));

    }

    default List<BpmExampleRule> getBpmExampleRuleByCodeAndKey(BpmExampleRule bpmExampleRule){
        return selectList(new QueryWrapperX<BpmExampleRule>()
                .eq("BUSINESS_KEY",bpmExampleRule.getBusinessKey())
                .eq("NODE_CODE",bpmExampleRule.getNodeCode()));
    }

    default BpmExampleRule getBpmExampleNodeRule(Map<String,String> map){
        return selectOne(new QueryWrapperX<BpmExampleRule>()
                .eq("BUSINESS_KEY",map.get("businessKey"))
                .eq("NODE_CODE",map.get("nodeCode"))
        );
    }
}
